﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel.PeerResolvers;

namespace RPGOnline.Server
{
    public partial class Form1 : Form
    {
        private ChatServer cprs;
        private ServiceHost host;

        public Form1()
        {
            InitializeComponent();
        }

        private void bnStart_Click(object sender, EventArgs e)
        {
            try
            {
                cprs = new ChatServer();
                host = new ServiceHost(cprs);
                host.Open();
				
                lbMessage.Text = "Server started successfully.";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                bnStart.Enabled = false;
                bnStop.Enabled = true;
            }

        }

        private void bnStop_Click(object sender, EventArgs e)
        {
            try
            {
                host.Close();
                lbMessage.Text = "Server stopped successfully.";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                bnStart.Enabled = true;
                bnStop.Enabled = false;
            }

        }
    }
}
